// JavaScript Document
/*添加私有链接*/
function addPrivateLink(type){
	switch(type){
		case "show":
			$(".div_mask").css("height",0);
			$("#div_mask_add_link").css("height",$(window).height()+'px');
		break;
		
		case "submit":
			if($("#form_add_link [name='add_link_url']").val() != "" && $("#form_add_link [name='add_link_name']").val() != ""){
				$("#form_add_link").submit();
			}else{
				alert("请将信息填写完全!");
			}
		break;
		
		case "reset":
			$("#div_mask_add_link").css("height",0);
		break;
	}
}

/*网站二级分类获取*/
function getType2Link(keyword,obj){
	$(".li_type2").css("background-color","#EEE");
	var data = new Array(keyword,obj);
	module = data;
	doAjax("getType2Link",data)
}

/*网站一级分类获取*/
function getTypeLink(keyword){
	module = keyword;
	
	$(".li_nav_link").css("border-bottom-color","#DDD").css("background-color","#EEE");
	$("#li_nav_link_"+keyword).css("background-color","#FFF").css("border-bottom-color","#FFF");
	//$("#div_ops_link").css("opacity",0);
	$("#div_ops_link").css("display",'none');
	doAjax("getTypeLink",keyword);
}

/*共有网络收藏*/
function cenPublicLink(type,data,obj){
	switch(type){
		case "show":
			if($("#"+data).css("opacity") != 1)
				$("#"+data+" .cenlink").animate({width:20},200);
		break;
	
		case "submit":
			if(isLogin == ""){alert("使用收藏功能,请先登录!"); return false;}
			var imgSrc = ($(obj).attr('src') == 
				web_root+'Public/Image/cen1.png')?web_root+'Public/Image/cen2.png':web_root+'Public/Image/cen1.png';
			$(obj).attr('src',imgSrc);
			doAjax("cenPublicLink",data);
		break;
		
		case "reset":
			if($("#"+data).css("opacity") == 1)
				$("#"+data+" .cenlink").animate({width:0},200);
		break;
	}
}

/*公有网站获取*/
function getPublicLink(){
	module = "mail";
	
	$(".li_nav_link").css("border-bottom-color","#DDD").css("background-color","#EEE");
	$("#li_link_pub").css("border-bottom-color","#FFF").css("background-color","#FFF");
	
	//$("#div_ops_link").css("opacity","0");
	$("#div_ops_link").css("display",'none');
	doAjax("getPublicLink",null);
}

/*私有网站获取*/
function getPrivateLink(){
	if(isLogin != ""){
		$(".li_nav_link").css("border-bottom-color","#DDD").css("background-color","#EEE");
		$("#li_link_pri").css("border-bottom-color","#FFF");
		
		//$("#div_ops_link").css("opacity","1");
		$("#div_ops_link").css("display",'block');
		
		$(".dellink").css("display","none");
		$("#edit_button").css("background-color","#EEE");
		editNum = 1;
		doAjax("getPrivateLink",null);
	}else{
		alert("使用收藏功能,请先登录!");
	}
}

/*删除私有链接*/
function delPrivateLink(type,data){
	switch(type){
		case "show":
			editNum++;
			if(editNum%2 == 0){
				$(".dellink").css("display","block");
				$("#edit_button").css("background-color","#F93");
			}else{
				$(".dellink").css("display","none");
				$("#edit_button").css("background-color","#EEE");
			}
			
		break;
		
		case "showOnce":
			if(data == 'edit'){$(".dellink").css("display","block");}
		break;
		
		case "submit":
			doAjax("delPrivateLink",data);
		break;
	}
}

/*网站链接点击记录*/
function toLinkLog(linkurl){
	doAjax('toLinkLog',linkurl);
}